Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git] / 11207 - The easiest way / p11207.cpp
blobb4becada45705cd9d33fd60666bbb71ebd409abc
1 #include <iostream>
2 #include <algorithm>
4 using namespace std;
6 #define MAX(a,b) (((a)>(b))?(a):(b))
7 #define MIN(a,b) (((a)<(b))?(a):(b))
9 int main(){
10 unsigned int n;
11 cin >> n;
12 while (n){
13 unsigned int vaGanando = 0;
14 double ganador = 0.0;
15 for (int i=1; i<=n; i++){ /* i nos dice en que pieza de papel vamos */
16 unsigned long h, w;
17 cin >> h >> w;
18 if (w > h) swap(w, h);
19 double maxPieza = MAX(MIN(h/4.0,w),MIN(h/2.0,w/2.0));
20 if (maxPieza > ganador){
21 ganador = maxPieza;
22 vaGanando = i;
25 cout << vaGanando << endl;
26 cin >> n;
28 return 0;